﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using Microsoft.Win32;

namespace FanaticGene.DesktopTest
{
    public partial class BilibiliHomeWindow : Window
    {
        public BilibiliHomeWindow()
        {
            InitializeComponent();
        }

        private void PlayMaskAnimation(double toValue)
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.2));
            animation.To = toValue;
            Mask.BeginAnimation(Ellipse.OpacityProperty, animation);
        }

        private void Rectangle_MouseEnter(object sender, MouseEventArgs e)
        {
            PlayMaskAnimation(0.5);
        }

        private void Rectangle_MouseLeave(object sender, MouseEventArgs e)
        {
            PlayMaskAnimation(0);
        }

        private void MaskButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();
            dialog.Filter = "图片|*.jpg;*.png";
            if (dialog.ShowDialog() == true)
            {
                var path = dialog.FileName;
                ico.ImageSource = new BitmapImage(new Uri(path));
            }
        }

        private void BtnChangeBackgroud_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();
            dialog.Filter = "图片|*.jpg;*.png";
            if(dialog.ShowDialog() == true)
            {
                var path = dialog.FileName;
                ImgBackground.Source = new BitmapImage(new Uri(path));
            }
        }
    }
}
